﻿using MediatR;

using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

using Tszy.API.Test1;
using Tszy.API.Test2;
using Tszy.Unlimited.Base.Infrastructure.Logging;
using Tszy.Unlimited.Base.Infrastructure.Stores;
using Tszy.Unlimited.Base.Models;

namespace Tszy.API.Controllers;

[Authorize(policy: "SystemPolicy")]
[ApiController]
public class HomeController : ControllerBase
{
    private readonly IMediator _mediator;
    private readonly IScopeStore? _scopeStore;
    private readonly Test11? test;

    public HomeController(IScopeStore scopeStore, Test11 test, IMediator mediator)
    {
        _scopeStore = scopeStore;
        this.test = test;
        _mediator = mediator;

        Console.WriteLine($"IScopeStore 的标识：{scopeStore.UniqueId}");
    }

    [HttpPost]
    [Route("api/test1")]
    public object Test1(Test11.Request request)
    {
        TszyLogger.Configs.Prefix = "[tszy]";
        TszyLogger.Instance.Error("123", new Exception("aaaaa"));
        return new { Status = true, Data = 1, ErrorCode = string.Empty, ErrorMessage = string.Empty, ExceptionType = string.Empty };
    }
    [HttpPost]
    [Route("api/test2")]
    public async Task<ResponseResult> Test2(Test12.Request request)
    {
        return await _mediator.Send(request);
    }
}